﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using V5_Common;
using V5_BLL;
using V5_Model;
using System.IO;

namespace V5_EShop.Admin
{
    public partial class Admin_Product : BasicPage
    {
        private const string vProduct = "vProduct";
        public int ClassID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            ClassID = Input.SetInt(Request["ClassID"]);
            ViewState[vProduct] = " ClassID=" + ClassID;

            if (!this.IsPostBack)
            {
                Action = Input.SetString(Request["Action"]).Trim().ToLower();
                Type = Input.SetString(Request["Type"]).Trim().ToLower();
                Bind_TabSelect(Type);
                Bind_DropClassList();
                Bind_ProductFieldClass();
                Bind_ProductBrand();
                switch (Action)
                {
                    case "edit":
                        this.MultiViewList.ActiveViewIndex = 1;
                        #region 绑定产品编号
                        this.txtProductCode.Text = new BLLProduct().GetProductNo(
                            new BLLProduct().GetMaxId().ToString(),
                            DateTime.Now);
                        #endregion
                        break;
                    default:
                        Bind_gvList();
                        break;
                }
            }
        }
        /// <summary>
        /// 绑定品牌
        /// </summary>
        private void Bind_ProductBrand()
        {
            this.ddlProductBrand.DataSource = new BLLProductBrand().GetList(0, "", " ID Desc");
            this.ddlProductBrand.DataTextField = "BrandName";
            this.ddlProductBrand.DataValueField = "BrandName";
            this.ddlProductBrand.DataBind();

            this.ddlProductBrand.Items.Insert(0, new ListItem("请选择", ""));
        }
        //绑定数据
        private void Bind_gvList()
        {
            this.MultiViewList.ActiveViewIndex = 0;
            string strWhere = "";
            if (ViewState[vProduct] != null && Input.SetString(ViewState[vProduct]) != "")
            {
                strWhere = Input.SetString(ViewState[vProduct]);
            }
            int count = 0;
            DataSet ds = new BLLProduct().GetList(Pager.PageSize, Pager.CurrentPageIndex, strWhere, ref count);
            Pager.RecordCount = count;
            this.gvList.DataSource = ds;
            this.gvList.DataBind();
        }

        protected void Pager_PageChanged(object sender, EventArgs e)
        {
            Bind_gvList();
        }
        //数据编辑
        private void Bind_DataEdit(int id)
        {
            this.MultiViewList.ActiveViewIndex = 1;
            ModelProduct model = new BLLProduct().GetModel(id, true);
            if (model != null)
            {
                this.hfID.Value = model.ID.ToString();
                this.txtChannelID.Value = model.ChannelID.ToString();
                this.ddlClassID.SelectedIndex = this.ddlClassID.Items.IndexOf(this.ddlClassID.Items.FindByValue(model.ClassID.ToString()));
                this.txtProductName.Text = model.ProductName;
                this.txtProductKeysWords.Text = model.ProductKeysWords;
                this.txtProductCode.Text = model.ProductCode;
                this.txtProductBrand.Text = model.ProductBrand;
                this.txtProductUnit.Text = model.ProductUnit;
                this.txtProductWeight.Text = model.ProductWeight;
                this.txtProductMarketPrice.Text = model.ProductMarketPrice;
                this.txtProductMemberPrice.Text = model.ProductMemberPrice;
                this.txtProductMinPrice.Text = model.ProductMinPrice;
                this.txtProductBigPic.Text = model.ProductBigPic;
                #region//产品多图
                if (model.ProductMorePic.Length > 0)
                {
                    string[] strarr1 = model.ProductMorePic.Split(new string[] { "$$$$" }, StringSplitOptions.None);
                    if (strarr1.Length > 0)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add(new DataColumn("id"));
                        dt.Columns.Add(new DataColumn("more1"));
                        dt.Columns.Add(new DataColumn("more2"));
                        string datetimeid = DateTime.Now.ToString("yyyyMMddhhmmss");
                        int i = 0;
                        foreach (string item in strarr1)
                        {
                            string[] strarr2 = item.Split(new string[] { "||" }, StringSplitOptions.None);
                            DataRow row = dt.NewRow();
                            row["id"] = datetimeid + i;
                            row["more1"] = strarr2[0];
                            row["more2"] = strarr2[1];
                            dt.Rows.Add(row);
                            i++;
                        }
                        ViewState["vProductMorePic"] = dt;
                        this.dlProductMorePicList.DataSource = dt;
                        this.dlProductMorePicList.DataBind();
                    }
                }
                #endregion
                this.txtProductCount.Text = model.ProductCount.ToString();
                this.ddlSelectType.SelectedIndex = this.ddlSelectType.Items.IndexOf(this.ddlSelectType.Items.FindByValue(model.ProductFieldType.ToString()));
                //产品字段属性
                if (model.ProductFields.Length > 0)
                {
                    string[] strarr3 = model.ProductFields.Split(new string[] { "$$$$" }, StringSplitOptions.None);
                    if (strarr3.Length > 0)
                    {
                        int sid = Input.SetInt(model.ProductFieldType.ToString());
                        //读取产品属性类型
                        this.rpFieldList.DataSource = new BLLProductField().GetList(" Choice=1 and FClassID=" + Utils.FilterInjection(sid));
                        this.rpFieldList.DataBind();
                        this.rpFieldList2.DataSource = new BLLProductField().GetList(" Choice=0 and FClassID=" + Utils.FilterInjection(sid));
                        this.rpFieldList2.DataBind();
                        foreach (RepeaterItem item in rpFieldList.Items)
                        {
                            Label lbl = (Label)item.FindControl("lblFieldName");
                            HiddenField hf = (HiddenField)item.FindControl("hfFieldID");
                            TextBox tb = (TextBox)item.FindControl("txtFieldValue");
                            Repeater rp2 = (Repeater)item.FindControl("rpFieldList2");
                            #region
                            foreach (string s1 in strarr3)//
                            {
                                string[] strarr4 = s1.Split(new string[] { "||" }, StringSplitOptions.None);
                                //if (lbl.Text == strarr4[0])
                                if (hf.Value == strarr4[0])
                                {
                                    tb.Text = strarr4[1];
                                    string rp2s1 = tb.Text;
                                    if (rp2s1.IndexOf(',') > -1)
                                    {
                                        tb.Visible = false;
                                        string[] rp2s1arr = rp2s1.Split(',');
                                        foreach (string haha1 in rp2s1arr)
                                        {
                                            foreach (RepeaterItem item2 in rp2.Items)
                                            {
                                                CheckBox cb = (CheckBox)item2.FindControl("chksingle");
                                                if (cb.Text == haha1)
                                                {
                                                    cb.Checked = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                }

                if (model.ProductSingleFields.Length > 0)
                {
                    string[] sarr1 = model.ProductSingleFields.Split(new string[] { "||" }, StringSplitOptions.None);
                    foreach (RepeaterItem item in this.rpFieldList2.Items)
                    {
                        Label lbl = (Label)item.FindControl("lblTitle");
                        TextBox tb = (TextBox)item.FindControl("txtFieldName");
                        foreach (string s1 in sarr1)
                        {
                            string[] sarr2 = s1.Split(new string[] { ":" }, StringSplitOptions.None);
                            if (lbl.Text == sarr2[0])
                            {
                                tb.Text = sarr2[1];
                            }
                        }
                    }
                }
                this.chkIsPassed.Checked = model.IsPassed.ToString() == "1" ? true : false;
                this.cbIsOnSale.Checked = model.IsOnSale.ToString() == "1" ? true : false;
                this.cbIsRecommond.Checked = model.IsRecommond.ToString() == "1" ? true : false;
                this.cbIsHot.Checked = model.IsOnHot.ToString() == "1" ? true : false;
                this.cbIsNew.Checked = model.IsNew.ToString() == "1" ? true : false;
                this.cbIsSpecialOffer.Checked = model.IsSpecialOffer.ToString() == "1" ? true : false;
                this.cbPackage.Checked = model.Package.ToString() == "1" ? true : false;
                //this.txtShortContent.Text = model.ShortContent;
                this.txtContent.Value = model.Content;
                this.txtHits.Text = model.Hits.ToString();
                //相关产品
                if (model.ProductRelated.Length > 0 && model.ProductRelated != "")
                {
                    this.gvAboutProduct.DataSource = new BLLProduct().GetList(0, " ID in(" + model.ProductRelated + ") ", " ID desc");

                    this.gvAboutProduct.DataBind();
                    foreach (GridViewRow gvitem in this.gvAboutProduct.Rows)
                    {
                        CheckBox cb = (CheckBox)gvitem.FindControl("chkitem1");
                        cb.Checked = true;
                    }
                }
                //产品洗剂
                if (model.XjIDs != "" && model.XjIDs.Length > 0)
                {
                    foreach (string s in model.XjIDs.Split(new string[] { "," }, StringSplitOptions.None))
                    {
                        foreach (ListItem chkitem in this.chkboxListXiJi.Items)
                        {
                            if (chkitem.Value == s)
                            {
                                chkitem.Selected = true;
                            }
                        }
                    }
                }
                this.lblTitle.Text = "修改产品";
                this.btnSave.Text = "保存修改";
            }
        }

        private void Bind_Delete(int id)
        {
            new BLLProduct().Delete(id, true);
            this.Bind_gvList();
        }
        /// <summary>
        /// 绑定字段类型
        /// </summary>
        private void Bind_ProductFieldClass()
        {
            DataTable dt = new BLLProductFieldClass().GetList("").Tables[0];
            this.ddlSelectType.DataSource = dt;
            this.ddlSelectType.DataTextField = "FieldClassName";
            this.ddlSelectType.DataValueField = "ID";
            this.ddlSelectType.DataBind();
            this.ddlSelectType.Items.Insert(0, new ListItem("请选择", "0"));
            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    if (dt.Rows[i][""].ToString() == "")
            //    {

            //    }
            //}
            DataTable dt1 = new BLLProductFieldClass().GetList(" IsSelected=1 ").Tables[0];
            if (dt1 != null)
            {
                int sid = Input.SetInt(dt1.Rows[0]["ID"]);
                this.ddlSelectType.SelectedIndex = this.ddlSelectType.Items.IndexOf(this.ddlSelectType.Items.FindByValue(sid.ToString()));
                //读取产品属性类型
                this.rpFieldList.DataSource = new BLLProductField().GetList(" Choice=1 and FClassID=" + Utils.FilterInjection(sid));
                this.rpFieldList.DataBind();
                this.rpFieldList2.DataSource = new BLLProductField().GetList(" Choice=0 and FClassID=" + Utils.FilterInjection(sid));
                this.rpFieldList2.DataBind();
            }

        }
        /// <summary>
        /// 绑定分类
        /// </summary>
        private void Bind_DropClassList()
        {
            this.ddlClassID.DataSource = new BLLProductClass().GetDropDownList("请选择", 0);
            this.ddlClassID.DataTextField = "ClassName";
            this.ddlClassID.DataValueField = "ClassID";
            this.ddlClassID.DataBind();

            if (ClassID > 0)
            {
                this.ddlClassID.SelectedValue = ClassID.ToString();
            }
        }

        private void Bind_TabSelect(string type)
        {
            switch (type)
            {
                case "ispassed":
                    TabSelect2 = "select";
                    break;
                case "nopassed":
                    TabSelect3 = "select";
                    break;
                case "isalert":
                    TabSelect4 = "select";
                    break;
                default:
                    TabSelect1 = "select";
                    break;
            }
        }
        //添加 编辑
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ModelProduct model = new ModelProduct();
            BLLProduct bll = new BLLProduct();
            int ID = Input.SetInt(this.hfID.Value);
            int ChannelID = Input.SetInt(this.txtChannelID.Value);
            int ClassID = Input.SetInt(this.ddlClassID.SelectedValue);
            string ProductName = this.txtProductName.Text;
            string ProductKeysWords = this.txtProductKeysWords.Text;
            string ProductCode = this.txtProductCode.Text;
            string ProductBrand = this.txtProductBrand.Text;
            string ProductUnit = this.txtProductUnit.Text;
            string ProductWeight = this.txtProductWeight.Text;
            string ProductMarketPrice = this.txtProductMarketPrice.Text;
            string ProductMemberPrice = this.txtProductMemberPrice.Text;
            string ProductMinPrice = this.txtProductMinPrice.Text;
            string ProductSmallPic = "";
            string ProductBigPic = this.txtProductBigPic.Text;
            #region 产品多图
            string ProductMorePic = "";
            if (ViewState["vProductMorePic"] != null)
            {
                DataTable dt = (DataTable)ViewState["vProductMorePic"];
                string tempStr = "";
                foreach (DataRow item in dt.Rows)
                {
                    tempStr += item["more1"] + "||" + item["more2"] + "$$$$";
                }
                if (tempStr.Length > 0)
                {
                    tempStr = tempStr.Remove(tempStr.Length - 4);
                }
                ProductMorePic = tempStr;
            }
            #endregion 产品多图结束
            int ProductCount = Input.SetInt(this.txtProductCount.Text);
            int ProductFieldType = Input.SetInt(this.ddlSelectType.SelectedValue);
            #region 产品字段属性
            string ProductFields = "";
            if (ProductFieldType > 0)
            {
                string tempStr1 = "";
                foreach (RepeaterItem item in rpFieldList.Items)
                {
                    string fieldvalues = "";
                    HiddenField hf = (HiddenField)item.FindControl("hfFieldID");
                    Repeater rp2 = (Repeater)item.FindControl("rpFieldList2");
                    TextBox tb = (TextBox)item.FindControl("txtFieldValue");
                    if (tb.Visible == false)
                    {
                        foreach (RepeaterItem item2 in rp2.Items)
                        {
                            CheckBox cb = (CheckBox)item2.FindControl("chksingle");
                            if (cb.Checked)
                            {
                                fieldvalues += cb.Text + ",";
                            }
                        }
                        if (fieldvalues.Length > 0)
                        {
                            fieldvalues = fieldvalues.Remove(fieldvalues.Length - 1);
                        }
                    }
                    else
                    {
                        fieldvalues = tb.Text;
                    }
                    string s1 = Input.SetString(hf.Value);
                    string s2 = Input.SetString(fieldvalues);
                    tempStr1 += s1 + "||" + s2 + "$$$$";
                }
                if (tempStr1.Length > 0)
                {
                    tempStr1 = tempStr1.Remove(tempStr1.Length - 4);
                }
                ProductFields = tempStr1;
            }
            #endregion

            string ProductSizeTable = this.txtProductSizeTable.Value;
            string ProductSingleFields = "";
            foreach (RepeaterItem item in this.rpFieldList2.Items)
            {
                Label lbl = (Label)item.FindControl("lblTitle");
                TextBox tb = (TextBox)item.FindControl("txtFieldName");
                ProductSingleFields += lbl.Text + ":" + tb.Text + "||";
            }

            if (ProductSingleFields.Length > 0)
            {
                ProductSingleFields = ProductSingleFields.Remove(ProductSingleFields.Length - 2);
            }
            int IsPassed = this.chkIsPassed.Checked ? 1 : 0;
            int IsOnSale = this.cbIsOnSale.Checked ? 1 : 0;
            int IsRecommond = this.cbIsRecommond.Checked ? 1 : 0;
            int IsOnHot = this.cbIsHot.Checked ? 1 : 0;
            int IsNew = this.cbIsNew.Checked ? 1 : 0;
            int IsSpecialOffer = this.cbIsSpecialOffer.Checked ? 1 : 0;
            int PackPage = this.cbPackage.Checked ? 1 : 0;
            string ShortContent = "";
            string Content = this.txtContent.Value;
            int Hits = int.Parse(this.txtHits.Text);
            DateTime AddDateTime = DateTime.Now;
            DateTime UpDateTime = DateTime.Now;
            //洗剂
            string xjClassID = "";
            foreach (ListItem chkitem in this.chkboxListXiJi.Items)
            {
                if (chkitem.Selected)
                {
                    xjClassID += chkitem.Value + ",";
                }
            }
            if (xjClassID.Length > 0)
            {
                xjClassID = xjClassID.Remove(xjClassID.Length - 1);
            }
            #region 相关产品
            string ProductRelated = "";
            foreach (GridViewRow gvitem in this.gvAboutProduct.Rows)
            {
                CheckBox cb = (CheckBox)gvitem.FindControl("chkitem1");
                string spid = gvitem.Cells[1].Text;
                if (cb.Checked)
                {
                    ProductRelated += spid + ",";
                }
            }
            if (ProductRelated.Length > 0 && ProductRelated != "")
            {
                ProductRelated = ProductRelated.Remove(ProductRelated.Length - 1);
            }
            #endregion

            //验证
            string strErr = "";
            if (ProductName == "")
            {
                strErr +="产品名称不能为空!\n\n";
            }
            if (strErr != "")
            {
                Js.Alert(strErr);
                return;
            }
            model.ChannelID = ChannelID;
            model.ClassID = ClassID;
            model.ProductName = ProductName;
            model.ProductKeysWords = ProductKeysWords;
            model.ProductCode = ProductCode;
            model.ProductBrand = ProductBrand;
            model.ProductUnit = ProductUnit;
            model.ProductWeight = ProductWeight;
            model.ProductMarketPrice = ProductMarketPrice;
            model.ProductMemberPrice = ProductMemberPrice;
            model.ProductMinPrice = ProductMinPrice;
            model.ProductBigPic = ProductBigPic;
            model.ProductSmallPic = ProductSmallPic;
            model.ProductMorePic = ProductMorePic;
            model.ProductCount = ProductCount;
            model.ProductFieldType = ProductFieldType;
            model.ProductFields = ProductFields;
            model.IsPassed = IsPassed;
            model.IsOnSale = IsOnSale;
            model.IsRecommond = IsRecommond;
            model.IsOnHot = IsOnHot;
            model.IsNew = IsNew;
            model.IsSpecialOffer = IsSpecialOffer;
            model.Package = PackPage;
            model.ShortContent = ShortContent;
            model.Content = Content;
            model.Hits = Hits;
            model.AddDateTime = AddDateTime;
            model.UpDateTime = UpDateTime;
            model.ProductRelated = ProductRelated;

            model.ProductSizeTable = ProductSizeTable;
            model.ProductSingleFields = ProductSingleFields;

            model.XjIDs = xjClassID;
            if (ID == 0)
            {
                model.ID = bll.GetMaxId();
                bll.Add(model);
            }
            else if (ID > 0)
            {
                model.ID = ID;
                bll.Update(model);
            }
            this.Bind_gvList();
        }

        //字段类型关联
        protected void ddlSelectType_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = Input.SetInt(this.ddlSelectType.SelectedValue);
            if (id > 0)
            {
                this.rpFieldList.DataSource = new BLLProductField().GetList(" Choice=1 and FClassID=" + Utils.FilterInjection(id));
                this.rpFieldList.DataBind();

                rpFieldList2.DataSource = new BLLProductField().GetList(" Choice=0 and FClassID=" + Utils.FilterInjection(id));
                rpFieldList2.DataBind();
            }
        }

        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string eName = Input.SetString(e.CommandName);
            int id = Input.SetInt(e.CommandArgument);
            switch (eName.ToLower().Trim())
            {
                case "go":
                    Bind_DataEdit(id);
                    break;
                case "del":
                    Bind_Delete(id);
                    break;
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string sTitle = Input.SetString(this.txtSearchText.Text);
            if (sTitle != "")
            {
                ViewState[vProduct] = " ProductName like '%" + Utils.FilterInjection(sTitle) + "%' ";
            }
            Bind_gvList();
        }

        protected void btnAll_Click(object sender, EventArgs e)
        {
            BLLProduct bll = new BLLProduct();
            int opType = Input.SetInt(this.ddlAll.SelectedValue);
            if (opType == 0)
            {
                Pr.RegClientAlert(this, "请选择一个操作类型!");
                return;
            }
            foreach (System.Web.UI.WebControls.GridViewRow item in this.gvList.Rows)
            {
                CheckBox chk = (CheckBox)item.FindControl("chkitem");
                int id = Input.SetInt(item.Cells[1].Text);
                if (chk.Checked)
                {
                    switch (opType)
                    {
                        case 1:
                            bll.Delete(id, true);
                            break;
                        default:
                            break;
                    }
                }
            }
            this.Bind_gvList();
        }

        /// <summary>
        /// 产品多图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void txtProductMorePicSave_Click(object sender, EventArgs e)
        {
            DataTable dt = null;
            string s1 = txtProductMorePicReadme.Text;
            string s2 = txtProductMorePicSelect.Text;
            string sid = Input.SetString(this.hfsID.Value);
            if (sid == "")
            {
                if (ViewState["vProductMorePic"] != null)
                {
                    dt = (DataTable)ViewState["vProductMorePic"];
                }
                else
                {
                    dt = new DataTable();
                    dt.Columns.Add("id");
                    dt.Columns.Add("more1");
                    dt.Columns.Add("more2");
                }
                DataRow row = dt.NewRow();
                row["id"] = DateTime.Now.ToString("yyyyMMddhhmmss");
                row["more1"] = s1;
                row["more2"] = s2;
                dt.Rows.Add(row);
                ViewState["vProductMorePic"] = dt;

                this.dlProductMorePicList.DataSource = dt;
                this.dlProductMorePicList.DataBind();
            }
            else
            {
                if (ViewState["vProductMorePic"] != null)
                {
                    dt = (DataTable)ViewState["vProductMorePic"];
                    DataRow[] rowarr = dt.Select(" id=" + sid);
                    foreach (DataRow item in rowarr)
                    {
                        item["more1"] = s1;
                        item["more2"] = s2;
                    }
                    dt.AcceptChanges();
                    ViewState["vProductMorePic"] = dt;
                    this.dlProductMorePicList.DataSource = dt;
                    this.dlProductMorePicList.DataBind();
                }
            }
            txtProductMorePicReadme.Text = "";
            txtProductMorePicSelect.Text = "";
            this.hfsID.Value = "";
            this.txtProductMorePicSave.Text = "添加";
        }

        private void Bind_MorePic(DataTable dt)
        {
            DataTable productpicTable = new DataTable();
            productpicTable.Columns.Add("more1");
            productpicTable.Columns.Add("more2");
            if (dt != null && dt.Rows.Count > 0)
            {

            }
        }
        /// <summary>
        /// 删除多图
        /// </summary>
        /// <param name="sid"></param>
        private void Bind_DeleteMorePic(string sid)
        {
            DataTable dt = null;
            if (ViewState["vProductMorePic"] != null)
            {
                dt = (DataTable)ViewState["vProductMorePic"];
                DataRow[] rowarr = dt.Select(" id=" + sid);
                foreach (DataRow item in rowarr)
                {
                    dt.Rows.Remove(item);
                }
                dt.AcceptChanges();
                ViewState["vProductMorePic"] = dt;
                this.dlProductMorePicList.DataSource = dt;
                this.dlProductMorePicList.DataBind();
            }
        }
        /// <summary>
        /// 修改多图
        /// </summary>
        /// <param name="sid"></param>
        private void Bind_EditMorePic(string sid)
        {
            DataTable dt = null;
            if (ViewState["vProductMorePic"] != null)
            {
                dt = (DataTable)ViewState["vProductMorePic"];
                DataRow[] rowarr = dt.Select(" id=" + sid);
                foreach (DataRow item in rowarr)
                {
                    this.txtProductMorePicReadme.Text = item["more1"].ToString();
                    this.txtProductMorePicSelect.Text = item["more2"].ToString();
                    this.txtProductMorePicSave.Text = "更新";
                    this.hfsID.Value = item["id"].ToString();
                }
            }
        }
        /// <summary>
        /// 多图命令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dlProductMorePicList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string eName = Input.SetString(e.CommandName);
            string sid = Input.SetString(e.CommandArgument);
            switch (eName.Trim().ToLower())
            {
                case "picgo":
                    Bind_EditMorePic(sid);
                    break;
                case "picdel":
                    Bind_DeleteMorePic(sid);
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// 属性字段绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rpFieldList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            TextBox tb = (TextBox)e.Item.FindControl("txtFieldValue");
            Repeater rp2 = (Repeater)e.Item.FindControl("rpFieldList2");
            string fieldvalue = tb.Text;
            if (fieldvalue.IndexOf(",") > -1)
            {
                tb.Visible = false;
                string[] farr1 = fieldvalue.Split(',');
                DataTable dt1 = new DataTable();
                dt1.Columns.Add("singlefield");
                foreach (string item in farr1)
                {
                    DataRow row1 = dt1.NewRow();
                    row1["singlefield"] = item;
                    dt1.Rows.Add(row1);
                }

                rp2.DataSource = dt1;
                rp2.DataBind();
            }
        }
        /// <summary>
        /// 搜索相关产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearchProduct_Click(object sender, EventArgs e)
        {
            string likeProduct = txtProductRelated.Text;
            if (likeProduct.Length > 0)
            {
                this.gvAboutProduct.DataSource = new BLLProduct().GetList(10, " ProductName like '%" + Utils.FilterInjection(likeProduct) + "%' ", " ID DEsc ");
                this.gvAboutProduct.DataBind();
            }
        }
    }
}
